/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/*
 * ProvaView.java
 *
 * Created on 18/06/2011, 17:39:06
 */
package view;

import controle.DisciplinaController;
import controle.QuestaoDiscursivaController;
import controle.QuestaoMultiplaEscolhaController;
import java.awt.event.ActionEvent;
import java.io.File;
import java.io.FileWriter;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.swing.DefaultListModel;
import javax.swing.JComboBox;
import javax.swing.JFileChooser;
import javax.swing.JOptionPane;
import javax.swing.filechooser.FileFilter;
import modelo.Alternativa;
import modelo.Dificuldade;
import modelo.Disciplina;
import modelo.QuestaoDiscursiva;
import modelo.QuestaoMultiplaEscolha;
import modelo.QuestaoProva;
import modelo.Topico;

/**
 *
 * @author Izabella
 */
public class ProvaView extends javax.swing.JFrame {

    private Integer idDisciplina;
    private Integer idQuestaoDiscursiva;

    /** Creates new form ProvaView */
    public ProvaView() {
        initComponents();
    }

    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        grupoOpcoesDificuldade = new javax.swing.ButtonGroup();
        grupoGabaritoME = new javax.swing.ButtonGroup();
        grupoOpcoesQuestao = new javax.swing.ButtonGroup();
        frameProva = new javax.swing.JFrame();
        jPanel1 = new javax.swing.JPanel();
        buttonImprimirProva = new javax.swing.JButton();
        buttonImprimirGabarito = new javax.swing.JButton();
        labelQuestoesProva = new javax.swing.JLabel();
        jScrollPane4 = new javax.swing.JScrollPane();
        textQuestoesProva = new javax.swing.JTextArea();
        jTabbedPane1 = new javax.swing.JTabbedPane();
        AbaDisciplina = new javax.swing.JPanel();
        labelNomeDisciplina = new javax.swing.JLabel();
        textNomeDisciplina = new javax.swing.JTextField();
        buttonConsultarDisciplina = new javax.swing.JButton();
        buttonExcluirDisciplina = new javax.swing.JButton();
        buttonCriarDisciplina = new javax.swing.JButton();
        labelCodigo = new javax.swing.JLabel();
        textCodigo = new javax.swing.JTextField();
        labelTopico = new javax.swing.JLabel();
        textTopico = new javax.swing.JTextField();
        buttonAdicionarTopico = new javax.swing.JToggleButton();
        jScrollPane3 = new javax.swing.JScrollPane();
        listTopicosDisciplina = new javax.swing.JList(listTopicosDisciplinaModel);
        buttonAlterarDisciplina = new javax.swing.JButton();
        AbaQuestao = new javax.swing.JPanel();
        jScrollPane5 = new javax.swing.JScrollPane();
        textEnunciado = new javax.swing.JTextArea();
        labelEnunciado = new javax.swing.JLabel();
        labelDisciplina = new javax.swing.JLabel();
        comboDisciplinaQuestao = new javax.swing.JComboBox();
        List<Disciplina> disciplinasQuestao = DisciplinaController.listar();
        comboDisciplinaQuestao.addItem("Selecione uma Disciplina");
        for(Disciplina item : disciplinasQuestao){
            comboDisciplinaQuestao.addItem(item);
        }
        jPanel6 = new javax.swing.JPanel();
        labelDificuldade = new javax.swing.JLabel();
        radioDificuldadeFacil = new javax.swing.JRadioButton();
        radioDificuldadeMedio = new javax.swing.JRadioButton();
        radioDificuldadeDificil = new javax.swing.JRadioButton();
        labelTopicos = new javax.swing.JLabel();
        jTabbedPane2 = new javax.swing.JTabbedPane();
        AbaME = new javax.swing.JPanel();
        buttonExcluirME = new javax.swing.JButton();
        buttonCriarME = new javax.swing.JButton();
        jPanel7 = new javax.swing.JPanel();
        labelAlternativaE = new javax.swing.JLabel();
        textAlternativaE = new javax.swing.JTextField();
        labelAlternativaD = new javax.swing.JLabel();
        textAlternativaD = new javax.swing.JTextField();
        labelAlternativaC = new javax.swing.JLabel();
        textAlternativaC = new javax.swing.JTextField();
        labelAlternativaB = new javax.swing.JLabel();
        textAlternativaB = new javax.swing.JTextField();
        labelAlternativaA = new javax.swing.JLabel();
        textAlternativaA = new javax.swing.JTextField();
        labelGabaritoME = new javax.swing.JLabel();
        radioGabaritoA = new javax.swing.JRadioButton();
        radioGabaritoB = new javax.swing.JRadioButton();
        radioGabaritoC = new javax.swing.JRadioButton();
        radioGabaritoD = new javax.swing.JRadioButton();
        radioGabaritoE = new javax.swing.JRadioButton();
        AbaD = new javax.swing.JPanel();
        labelGabaritoD = new javax.swing.JLabel();
        textGabaritoD = new javax.swing.JTextField();
        buttonExcluirD = new javax.swing.JButton();
        buttonCriarD = new javax.swing.JButton();
        jScrollPane2 = new javax.swing.JScrollPane();
        listTopicosQuestao = new javax.swing.JList(listTopicosQuestaoModel);
        buttonConsultarQuestao = new javax.swing.JButton();
        radioDiscursiva = new javax.swing.JRadioButton();
        radioME = new javax.swing.JRadioButton();
        AbaProva = new javax.swing.JPanel();
        buttonGerarProva = new javax.swing.JButton();
        comboDisciplinaProva = new javax.swing.JComboBox();
        jScrollPane1 = new javax.swing.JScrollPane();
        listTopicosProva = new javax.swing.JList(listTopicosProvaModel);
        labelTopicosProva = new javax.swing.JLabel();
        labelDisciplinaProva = new javax.swing.JLabel();
        jPanel10 = new javax.swing.JPanel();
        jPanel9 = new javax.swing.JPanel();
        textQuestoesME = new javax.swing.JLabel();
        labelMEFaceis = new javax.swing.JLabel();
        labelMEDificeis = new javax.swing.JLabel();
        labelMEMedias = new javax.swing.JLabel();
        textMEDificil = new javax.swing.JTextField();
        textMEMedia = new javax.swing.JTextField();
        textMEFacil = new javax.swing.JTextField();
        jPanel8 = new javax.swing.JPanel();
        labelQuestoesD = new javax.swing.JLabel();
        labelDFaceis = new javax.swing.JLabel();
        labelDMedias = new javax.swing.JLabel();
        textDFacil = new javax.swing.JTextField();
        textDMedia = new javax.swing.JTextField();
        textDDificil = new javax.swing.JTextField();
        labelDDificeis = new javax.swing.JLabel();

        frameProva.setMinimumSize(new java.awt.Dimension(418, 320));
        frameProva.setResizable(false);

        buttonImprimirProva.setText("Imprimir Prova");

        buttonImprimirGabarito.setText("Imprimir Gabarito");

        labelQuestoesProva.setText("Questões");

        textQuestoesProva.setColumns(20);
        textQuestoesProva.setRows(5);
        jScrollPane4.setViewportView(textQuestoesProva);

        javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);
        jPanel1.setLayout(jPanel1Layout);
        jPanel1Layout.setHorizontalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel1Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanel1Layout.createSequentialGroup()
                        .addComponent(jScrollPane4, javax.swing.GroupLayout.DEFAULT_SIZE, 378, Short.MAX_VALUE)
                        .addContainerGap())
                    .addGroup(jPanel1Layout.createSequentialGroup()
                        .addComponent(labelQuestoesProva)
                        .addContainerGap(342, Short.MAX_VALUE))
                    .addGroup(jPanel1Layout.createSequentialGroup()
                        .addComponent(buttonImprimirProva, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                        .addGap(10, 10, 10)
                        .addComponent(buttonImprimirGabarito)
                        .addContainerGap(158, Short.MAX_VALUE))))
        );
        jPanel1Layout.setVerticalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel1Layout.createSequentialGroup()
                .addGap(11, 11, 11)
                .addComponent(labelQuestoesProva)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jScrollPane4, javax.swing.GroupLayout.PREFERRED_SIZE, 187, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(buttonImprimirGabarito)
                    .addComponent(buttonImprimirProva))
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );

        javax.swing.GroupLayout frameProvaLayout = new javax.swing.GroupLayout(frameProva.getContentPane());
        frameProva.getContentPane().setLayout(frameProvaLayout);
        frameProvaLayout.setHorizontalGroup(
            frameProvaLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, frameProvaLayout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jPanel1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addContainerGap())
        );
        frameProvaLayout.setVerticalGroup(
            frameProvaLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(frameProvaLayout.createSequentialGroup()
                .addComponent(jPanel1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addContainerGap())
        );

        setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);

        labelNomeDisciplina.setText("Nome da Disciplina");

        buttonConsultarDisciplina.setText("Consultar");
        buttonConsultarDisciplina.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                buttonConsultarDisciplinaActionPerformed(evt);
            }
        });

        buttonExcluirDisciplina.setText("Excluir");
        buttonExcluirDisciplina.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                buttonExcluirDisciplinaActionPerformed(evt);
            }
        });

        buttonCriarDisciplina.setText("Criar");
        buttonCriarDisciplina.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                buttonCriarDisciplinaActionPerformed(evt);
            }
        });

        labelCodigo.setText("Código");

        labelTopico.setText("Tópico");

        buttonAdicionarTopico.setText("Adicionar");
        buttonAdicionarTopico.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                buttonAdicionarTopicoActionPerformed(evt);
            }
        });

        jScrollPane3.setViewportView(listTopicosDisciplina);

        buttonAlterarDisciplina.setText("Alterar");
        buttonAlterarDisciplina.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                buttonAlterarDisciplinaActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout AbaDisciplinaLayout = new javax.swing.GroupLayout(AbaDisciplina);
        AbaDisciplina.setLayout(AbaDisciplinaLayout);
        AbaDisciplinaLayout.setHorizontalGroup(
            AbaDisciplinaLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(AbaDisciplinaLayout.createSequentialGroup()
                .addContainerGap()
                .addGroup(AbaDisciplinaLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(AbaDisciplinaLayout.createSequentialGroup()
                        .addGroup(AbaDisciplinaLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                            .addComponent(labelTopico)
                            .addComponent(labelNomeDisciplina)
                            .addComponent(labelCodigo))
                        .addGap(18, 18, 18)
                        .addGroup(AbaDisciplinaLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                            .addGroup(AbaDisciplinaLayout.createSequentialGroup()
                                .addComponent(textNomeDisciplina, javax.swing.GroupLayout.PREFERRED_SIZE, 126, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                                .addComponent(buttonConsultarDisciplina))
                            .addGroup(AbaDisciplinaLayout.createSequentialGroup()
                                .addGroup(AbaDisciplinaLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                                    .addComponent(textTopico, javax.swing.GroupLayout.Alignment.LEADING)
                                    .addComponent(textCodigo, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, 124, Short.MAX_VALUE)
                                    .addComponent(jScrollPane3, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, 124, Short.MAX_VALUE))
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                                .addComponent(buttonAdicionarTopico, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))))
                    .addGroup(AbaDisciplinaLayout.createSequentialGroup()
                        .addComponent(buttonExcluirDisciplina)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addComponent(buttonAlterarDisciplina)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addComponent(buttonCriarDisciplina, javax.swing.GroupLayout.PREFERRED_SIZE, 67, javax.swing.GroupLayout.PREFERRED_SIZE)))
                .addContainerGap(134, Short.MAX_VALUE))
        );
        AbaDisciplinaLayout.setVerticalGroup(
            AbaDisciplinaLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(AbaDisciplinaLayout.createSequentialGroup()
                .addGap(20, 20, 20)
                .addGroup(AbaDisciplinaLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(labelNomeDisciplina)
                    .addComponent(textNomeDisciplina, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(buttonConsultarDisciplina))
                .addGap(18, 18, 18)
                .addGroup(AbaDisciplinaLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(textCodigo, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(labelCodigo))
                .addGap(18, 18, 18)
                .addGroup(AbaDisciplinaLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(textTopico, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(buttonAdicionarTopico)
                    .addComponent(labelTopico))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addComponent(jScrollPane3, javax.swing.GroupLayout.PREFERRED_SIZE, 74, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(18, 18, 18)
                .addGroup(AbaDisciplinaLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(buttonExcluirDisciplina)
                    .addComponent(buttonAlterarDisciplina)
                    .addComponent(buttonCriarDisciplina))
                .addContainerGap(354, Short.MAX_VALUE))
        );

        jTabbedPane1.addTab("Cadastrar Disciplina", AbaDisciplina);

        textEnunciado.setColumns(20);
        textEnunciado.setRows(5);
        jScrollPane5.setViewportView(textEnunciado);

        labelEnunciado.setText("Enunciado");

        labelDisciplina.setText("Disciplina");

        comboDisciplinaQuestao.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                comboDisciplinaQuestaoActionPerformed(evt);
            }
        });

        labelDificuldade.setText("Dificuldade");

        radioDificuldadeFacil.setText("Fácil");
        grupoOpcoesDificuldade.add(radioDificuldadeFacil);

        radioDificuldadeMedio.setText("Médio");
        grupoOpcoesDificuldade.add(radioDificuldadeMedio);

        radioDificuldadeDificil.setText("Difícil");
        grupoOpcoesDificuldade.add(radioDificuldadeDificil);

        javax.swing.GroupLayout jPanel6Layout = new javax.swing.GroupLayout(jPanel6);
        jPanel6.setLayout(jPanel6Layout);
        jPanel6Layout.setHorizontalGroup(
            jPanel6Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel6Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel6Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(labelDificuldade)
                    .addComponent(radioDificuldadeFacil)
                    .addComponent(radioDificuldadeMedio)
                    .addComponent(radioDificuldadeDificil))
                .addContainerGap(37, Short.MAX_VALUE))
        );
        jPanel6Layout.setVerticalGroup(
            jPanel6Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel6Layout.createSequentialGroup()
                .addGroup(jPanel6Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanel6Layout.createSequentialGroup()
                        .addGap(21, 21, 21)
                        .addComponent(radioDificuldadeFacil)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addComponent(radioDificuldadeMedio)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(radioDificuldadeDificil))
                    .addComponent(labelDificuldade))
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );

        labelTopicos.setText("Tópicos");

        buttonExcluirME.setText("Excluir");
        buttonExcluirME.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                buttonExcluirMEActionPerformed(evt);
            }
        });

        buttonCriarME.setText("Cadastrar");
        buttonCriarME.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                buttonCriarMEActionPerformed(evt);
            }
        });

        labelAlternativaE.setText("Alternativa E");

        labelAlternativaD.setText("Alternativa D");

        labelAlternativaC.setText("Alternativa C");

        labelAlternativaB.setText("Alternativa B");

        labelAlternativaA.setText("Alternativa A");

        labelGabaritoME.setText("Gabarito");

        grupoGabaritoME.add(radioGabaritoA);

        grupoGabaritoME.add(radioGabaritoB);

        grupoGabaritoME.add(radioGabaritoC);

        grupoGabaritoME.add(radioGabaritoD);

        grupoGabaritoME.add(radioGabaritoE);

        javax.swing.GroupLayout jPanel7Layout = new javax.swing.GroupLayout(jPanel7);
        jPanel7.setLayout(jPanel7Layout);
        jPanel7Layout.setHorizontalGroup(
            jPanel7Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel7Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel7Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                    .addGroup(jPanel7Layout.createSequentialGroup()
                        .addGroup(jPanel7Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                            .addGroup(jPanel7Layout.createSequentialGroup()
                                .addComponent(labelAlternativaE)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 16, Short.MAX_VALUE)
                                .addComponent(textAlternativaE, javax.swing.GroupLayout.PREFERRED_SIZE, 263, javax.swing.GroupLayout.PREFERRED_SIZE))
                            .addGroup(jPanel7Layout.createSequentialGroup()
                                .addComponent(labelAlternativaD)
                                .addGap(16, 16, 16)
                                .addComponent(textAlternativaD))
                            .addGroup(jPanel7Layout.createSequentialGroup()
                                .addComponent(labelAlternativaC)
                                .addGap(16, 16, 16)
                                .addComponent(textAlternativaC))
                            .addGroup(jPanel7Layout.createSequentialGroup()
                                .addComponent(labelAlternativaB)
                                .addGap(18, 18, 18)
                                .addComponent(textAlternativaB))
                            .addGroup(jPanel7Layout.createSequentialGroup()
                                .addComponent(labelAlternativaA)
                                .addGap(18, 18, 18)
                                .addComponent(textAlternativaA, javax.swing.GroupLayout.PREFERRED_SIZE, 260, javax.swing.GroupLayout.PREFERRED_SIZE)))
                        .addGap(27, 27, 27)
                        .addGroup(jPanel7Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                            .addComponent(radioGabaritoE)
                            .addComponent(radioGabaritoD)
                            .addComponent(radioGabaritoC)
                            .addComponent(radioGabaritoB)
                            .addComponent(radioGabaritoA))
                        .addGap(25, 25, 25))
                    .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel7Layout.createSequentialGroup()
                        .addComponent(labelGabaritoME, javax.swing.GroupLayout.PREFERRED_SIZE, 49, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addContainerGap())))
        );
        jPanel7Layout.setVerticalGroup(
            jPanel7Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel7Layout.createSequentialGroup()
                .addComponent(labelGabaritoME)
                .addGap(8, 8, 8)
                .addGroup(jPanel7Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false)
                    .addGroup(jPanel7Layout.createSequentialGroup()
                        .addGroup(jPanel7Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(labelAlternativaA)
                            .addComponent(textAlternativaA, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addGap(19, 19, 19)
                        .addGroup(jPanel7Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(labelAlternativaB)
                            .addComponent(textAlternativaB, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)))
                    .addGroup(jPanel7Layout.createSequentialGroup()
                        .addComponent(radioGabaritoA)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                        .addComponent(radioGabaritoB)))
                .addGap(19, 19, 19)
                .addGroup(jPanel7Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel7Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                        .addComponent(textAlternativaC, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addComponent(labelAlternativaC))
                    .addComponent(radioGabaritoC, javax.swing.GroupLayout.Alignment.TRAILING))
                .addGap(18, 18, 18)
                .addGroup(jPanel7Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel7Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                        .addComponent(textAlternativaD, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addComponent(labelAlternativaD))
                    .addComponent(radioGabaritoD, javax.swing.GroupLayout.Alignment.TRAILING))
                .addGap(19, 19, 19)
                .addGroup(jPanel7Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(radioGabaritoE)
                    .addGroup(jPanel7Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                        .addComponent(textAlternativaE, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addComponent(labelAlternativaE)))
                .addContainerGap(43, Short.MAX_VALUE))
        );

        javax.swing.GroupLayout AbaMELayout = new javax.swing.GroupLayout(AbaME);
        AbaME.setLayout(AbaMELayout);
        AbaMELayout.setHorizontalGroup(
            AbaMELayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(AbaMELayout.createSequentialGroup()
                .addGroup(AbaMELayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(AbaMELayout.createSequentialGroup()
                        .addGap(7, 7, 7)
                        .addComponent(buttonExcluirME)
                        .addGap(18, 18, 18)
                        .addComponent(buttonCriarME))
                    .addGroup(AbaMELayout.createSequentialGroup()
                        .addContainerGap()
                        .addComponent(jPanel7, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)))
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );
        AbaMELayout.setVerticalGroup(
            AbaMELayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, AbaMELayout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jPanel7, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addGroup(AbaMELayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(buttonExcluirME)
                    .addComponent(buttonCriarME))
                .addContainerGap())
        );

        jTabbedPane2.addTab("Multipla Escolha", AbaME);

        labelGabaritoD.setText("Gabarito");

        buttonExcluirD.setText("Excluir");
        buttonExcluirD.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                buttonExcluirDActionPerformed(evt);
            }
        });

        buttonCriarD.setText("Cadastrar");
        buttonCriarD.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                buttonCriarDActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout AbaDLayout = new javax.swing.GroupLayout(AbaD);
        AbaD.setLayout(AbaDLayout);
        AbaDLayout.setHorizontalGroup(
            AbaDLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(AbaDLayout.createSequentialGroup()
                .addContainerGap()
                .addGroup(AbaDLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(labelGabaritoD)
                    .addComponent(textGabaritoD, javax.swing.GroupLayout.PREFERRED_SIZE, 285, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addGroup(AbaDLayout.createSequentialGroup()
                        .addComponent(buttonExcluirD)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addComponent(buttonCriarD)))
                .addContainerGap(147, Short.MAX_VALUE))
        );
        AbaDLayout.setVerticalGroup(
            AbaDLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(AbaDLayout.createSequentialGroup()
                .addContainerGap()
                .addComponent(labelGabaritoD)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(textGabaritoD, javax.swing.GroupLayout.PREFERRED_SIZE, 74, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addGroup(AbaDLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(buttonExcluirD)
                    .addComponent(buttonCriarD))
                .addContainerGap(167, Short.MAX_VALUE))
        );

        jTabbedPane2.addTab("Discursiva", AbaD);

        jScrollPane2.setViewportView(listTopicosQuestao);

        buttonConsultarQuestao.setText("Consultar");
        buttonConsultarQuestao.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                buttonConsultarQuestaoActionPerformed(evt);
            }
        });

        radioDiscursiva.setText("Discursiva");
        grupoOpcoesQuestao.add(radioDiscursiva);

        radioME.setText("Multipla Escolha");
        grupoOpcoesQuestao.add(radioME);
        radioME.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                radioMEActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout AbaQuestaoLayout = new javax.swing.GroupLayout(AbaQuestao);
        AbaQuestao.setLayout(AbaQuestaoLayout);
        AbaQuestaoLayout.setHorizontalGroup(
            AbaQuestaoLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(AbaQuestaoLayout.createSequentialGroup()
                .addGroup(AbaQuestaoLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(AbaQuestaoLayout.createSequentialGroup()
                        .addContainerGap()
                        .addGroup(AbaQuestaoLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(jTabbedPane2, javax.swing.GroupLayout.PREFERRED_SIZE, 447, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addGroup(AbaQuestaoLayout.createSequentialGroup()
                                .addGroup(AbaQuestaoLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                    .addComponent(labelDisciplina)
                                    .addComponent(comboDisciplinaQuestao, javax.swing.GroupLayout.PREFERRED_SIZE, 128, javax.swing.GroupLayout.PREFERRED_SIZE))
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                                .addGroup(AbaQuestaoLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                    .addComponent(jScrollPane2, javax.swing.GroupLayout.PREFERRED_SIZE, 152, javax.swing.GroupLayout.PREFERRED_SIZE)
                                    .addComponent(labelTopicos))
                                .addGap(18, 18, 18)
                                .addComponent(jPanel6, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))))
                    .addGroup(AbaQuestaoLayout.createSequentialGroup()
                        .addContainerGap()
                        .addComponent(radioDiscursiva)
                        .addGap(18, 18, 18)
                        .addComponent(radioME)
                        .addGap(18, 18, 18)
                        .addComponent(buttonConsultarQuestao))
                    .addGroup(AbaQuestaoLayout.createSequentialGroup()
                        .addContainerGap()
                        .addComponent(labelEnunciado))
                    .addComponent(jScrollPane5, javax.swing.GroupLayout.DEFAULT_SIZE, 457, Short.MAX_VALUE))
                .addContainerGap())
        );
        AbaQuestaoLayout.setVerticalGroup(
            AbaQuestaoLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(AbaQuestaoLayout.createSequentialGroup()
                .addContainerGap()
                .addGroup(AbaQuestaoLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                    .addComponent(jPanel6, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addGroup(AbaQuestaoLayout.createSequentialGroup()
                        .addGroup(AbaQuestaoLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(labelDisciplina)
                            .addComponent(labelTopicos))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addGroup(AbaQuestaoLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(comboDisciplinaQuestao, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addGroup(AbaQuestaoLayout.createSequentialGroup()
                                .addComponent(jScrollPane2, javax.swing.GroupLayout.PREFERRED_SIZE, 64, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addGap(18, 18, 18)
                                .addGroup(AbaQuestaoLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                                    .addComponent(buttonConsultarQuestao)
                                    .addComponent(radioME)
                                    .addComponent(radioDiscursiva))))))
                .addGap(26, 26, 26)
                .addComponent(labelEnunciado)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jScrollPane5, javax.swing.GroupLayout.PREFERRED_SIZE, 60, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(18, 18, 18)
                .addComponent(jTabbedPane2, javax.swing.GroupLayout.DEFAULT_SIZE, 331, Short.MAX_VALUE)
                .addContainerGap())
        );

        jTabbedPane1.addTab("Cadastrar Questão", AbaQuestao);

        buttonGerarProva.setText("Gerar Prova");
        buttonGerarProva.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                buttonGerarProvaActionPerformed(evt);
            }
        });

        List<Disciplina> disciplinasProva = DisciplinaController.listar();
        comboDisciplinaProva.addItem("Selecione uma Disciplina");
        for(Disciplina item : disciplinasProva){
            comboDisciplinaProva.addItem(item);
        }
        comboDisciplinaProva.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                comboDisciplinaProvaActionPerformed(evt);
            }
        });

        jScrollPane1.setViewportView(listTopicosProva);

        labelTopicosProva.setText("Tópicos");

        labelDisciplinaProva.setText("Disciplina");

        textQuestoesME.setText("Questões Multipla-Escolha");

        labelMEFaceis.setText("Fáceis");

        labelMEDificeis.setText("Difíceis");

        labelMEMedias.setText("Médias");

        textMEDificil.setText("0");

        textMEMedia.setText("0");

        textMEFacil.setText("0");

        javax.swing.GroupLayout jPanel9Layout = new javax.swing.GroupLayout(jPanel9);
        jPanel9.setLayout(jPanel9Layout);
        jPanel9Layout.setHorizontalGroup(
            jPanel9Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel9Layout.createSequentialGroup()
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addGroup(jPanel9Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanel9Layout.createSequentialGroup()
                        .addGroup(jPanel9Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(labelMEFaceis)
                            .addComponent(labelMEMedias)
                            .addComponent(labelMEDificeis))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addGroup(jPanel9Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                            .addComponent(textMEMedia)
                            .addComponent(textMEDificil)
                            .addComponent(textMEFacil, javax.swing.GroupLayout.PREFERRED_SIZE, 57, javax.swing.GroupLayout.PREFERRED_SIZE)))
                    .addComponent(textQuestoesME, javax.swing.GroupLayout.PREFERRED_SIZE, 135, javax.swing.GroupLayout.PREFERRED_SIZE)))
        );
        jPanel9Layout.setVerticalGroup(
            jPanel9Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel9Layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(textQuestoesME)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addGroup(jPanel9Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(textMEFacil, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(labelMEFaceis))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addGroup(jPanel9Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(textMEMedia, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(labelMEMedias))
                .addGap(12, 12, 12)
                .addGroup(jPanel9Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(textMEDificil, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(labelMEDificeis))
                .addContainerGap(15, Short.MAX_VALUE))
        );

        labelQuestoesD.setText("Questões Discursivas");

        labelDFaceis.setText("Fáceis");

        labelDMedias.setText("Médias");

        textDFacil.setText("0");

        textDMedia.setText("0");

        textDDificil.setText("0");

        labelDDificeis.setText("Difíceis");

        javax.swing.GroupLayout jPanel8Layout = new javax.swing.GroupLayout(jPanel8);
        jPanel8.setLayout(jPanel8Layout);
        jPanel8Layout.setHorizontalGroup(
            jPanel8Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel8Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel8Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanel8Layout.createSequentialGroup()
                        .addComponent(labelQuestoesD)
                        .addContainerGap(23, Short.MAX_VALUE))
                    .addGroup(jPanel8Layout.createSequentialGroup()
                        .addGroup(jPanel8Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addGroup(jPanel8Layout.createSequentialGroup()
                                .addComponent(labelDDificeis)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addComponent(textDDificil, javax.swing.GroupLayout.PREFERRED_SIZE, 54, javax.swing.GroupLayout.PREFERRED_SIZE))
                            .addGroup(jPanel8Layout.createSequentialGroup()
                                .addGroup(jPanel8Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                    .addComponent(labelDFaceis)
                                    .addComponent(labelDMedias))
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addGroup(jPanel8Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                    .addComponent(textDFacil, javax.swing.GroupLayout.DEFAULT_SIZE, 54, Short.MAX_VALUE)
                                    .addComponent(textDMedia, javax.swing.GroupLayout.DEFAULT_SIZE, 54, Short.MAX_VALUE))))
                        .addGap(34, 34, 34))))
        );
        jPanel8Layout.setVerticalGroup(
            jPanel8Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel8Layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(labelQuestoesD)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addGroup(jPanel8Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(labelDFaceis)
                    .addComponent(textDFacil, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addGroup(jPanel8Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(labelDMedias)
                    .addComponent(textDMedia, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addGroup(jPanel8Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(textDDificil, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(labelDDificeis))
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );

        javax.swing.GroupLayout jPanel10Layout = new javax.swing.GroupLayout(jPanel10);
        jPanel10.setLayout(jPanel10Layout);
        jPanel10Layout.setHorizontalGroup(
            jPanel10Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel10Layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jPanel9, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(18, 18, 18)
                .addComponent(jPanel8, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap(44, Short.MAX_VALUE))
        );
        jPanel10Layout.setVerticalGroup(
            jPanel10Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel10Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel10Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jPanel8, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jPanel9, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );

        javax.swing.GroupLayout AbaProvaLayout = new javax.swing.GroupLayout(AbaProva);
        AbaProva.setLayout(AbaProvaLayout);
        AbaProvaLayout.setHorizontalGroup(
            AbaProvaLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(AbaProvaLayout.createSequentialGroup()
                .addContainerGap()
                .addGroup(AbaProvaLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(AbaProvaLayout.createSequentialGroup()
                        .addGap(10, 10, 10)
                        .addComponent(buttonGerarProva))
                    .addGroup(AbaProvaLayout.createSequentialGroup()
                        .addGroup(AbaProvaLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(labelDisciplinaProva)
                            .addComponent(comboDisciplinaProva, javax.swing.GroupLayout.PREFERRED_SIZE, 126, javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addGap(18, 18, 18)
                        .addGroup(AbaProvaLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(labelTopicosProva)
                            .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 150, javax.swing.GroupLayout.PREFERRED_SIZE)))
                    .addComponent(jPanel10, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addContainerGap(105, Short.MAX_VALUE))
        );
        AbaProvaLayout.setVerticalGroup(
            AbaProvaLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(AbaProvaLayout.createSequentialGroup()
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addGroup(AbaProvaLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(labelDisciplinaProva)
                    .addComponent(labelTopicosProva))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(AbaProvaLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(comboDisciplinaProva, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 65, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(59, 59, 59)
                .addComponent(jPanel10, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(buttonGerarProva)
                .addGap(362, 362, 362))
        );

        // Código adicionando o componente ao contêiner pai - não mostrado aqui

        jTabbedPane1.addTab("Gerar Prova", AbaProva);

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jTabbedPane1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addComponent(jTabbedPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 627, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );

        pack();
    }// </editor-fold>//GEN-END:initComponents

    //metodo que cria nova disciplina
    private void buttonCriarDisciplinaActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_buttonCriarDisciplinaActionPerformed
        try {
            Validator.checkCampoVazio(textNomeDisciplina.getText());
            idDisciplina = null; //define null para nao chamar metodo DisciplinaController.alterar               

            cadastrarDisciplina();

            JOptionPane.showMessageDialog(rootPane, Validator.MSG_DISCIPLINA_CRIADA);
            limparFormularioDisciplina();
        } catch (Exception e) {
            JOptionPane.showMessageDialog(rootPane, e.getMessage(), "Erro", JOptionPane.ERROR_MESSAGE);
            //Logger.getLogger(ProvaView.class.getName()).log(Level.SEVERE, null, e);
        }
    }//GEN-LAST:event_buttonCriarDisciplinaActionPerformed

    //metodo que altera disciplina já cadastrada
    private void buttonAlterarDisciplinaActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_buttonAlterarDisciplinaActionPerformed
        try {

            Validator.checkCampoVazio(textNomeDisciplina.getText());

            if (idDisciplina == null) { //verifica se disciplina foi consultada
                throw new Exception(Validator.MSG_CONSULTA_NECESSARIA);
            }

            cadastrarDisciplina();

            JOptionPane.showMessageDialog(rootPane, Validator.MSG_DISCIPLINA_ALTERADA);
            limparFormularioDisciplina();
        } catch (Exception e) {
            JOptionPane.showMessageDialog(rootPane, e.getMessage(), "Erro", JOptionPane.ERROR_MESSAGE);
        }
    }//GEN-LAST:event_buttonAlterarDisciplinaActionPerformed

    //metodo que exclui disciplina já cadastrada
    private void buttonExcluirDisciplinaActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_buttonExcluirDisciplinaActionPerformed

        try {
            Validator.checkCampoVazio(textNomeDisciplina.getText());

            if (idDisciplina == null) { //verifica efetuou consulta
                throw new Exception(Validator.MSG_CONSULTA_NECESSARIA);
            }

            DisciplinaController.excluir(idDisciplina);
            JOptionPane.showMessageDialog(rootPane, Validator.MSG_DISCIPLINA_EXCLUIDA);
            limparFormularioDisciplina();
            idDisciplina = null;

        } catch (Exception e) {
            JOptionPane.showMessageDialog(rootPane, e.getMessage(), "Erro", JOptionPane.ERROR_MESSAGE);
        }
    }//GEN-LAST:event_buttonExcluirDisciplinaActionPerformed

    private void buttonConsultarDisciplinaActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_buttonConsultarDisciplinaActionPerformed

        try {
            Validator.checkCampoVazio(textNomeDisciplina.getText());

            Disciplina disciplina = DisciplinaController.consultar(textNomeDisciplina.getText());

            limparFormularioDisciplina();

            textNomeDisciplina.setText(disciplina.getNomeDisciplina());
            textCodigo.setText(disciplina.getCodDisciplina());

            for (Topico item : disciplina.getTopicos()) {
                listTopicosDisciplinaModel.addElement(item.getNmTopico());
            }
            idDisciplina = disciplina.getIdDisciplina();

        } catch (Exception e) {
            JOptionPane.showMessageDialog(rootPane, e.getMessage(), "Erro", JOptionPane.ERROR_MESSAGE);
        }
    }//GEN-LAST:event_buttonConsultarDisciplinaActionPerformed

    private void buttonConsultarQuestaoActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_buttonConsultarQuestaoActionPerformed
        try {
            if (radioDiscursiva.isSelected()) {
                consultarQuestaoDiscursiva();
            } else if (radioME.isSelected()) {
                consultarQuestaoME();
            }
        } catch (Exception e) {
            JOptionPane.showMessageDialog(rootPane, e.getMessage(), "Erro", JOptionPane.ERROR_MESSAGE);
            //Logger.getLogger(ProvaView.class.getName()).log(Level.SEVERE, null, e);
            
        }
    }//GEN-LAST:event_buttonConsultarQuestaoActionPerformed

    private void consultarQuestaoDiscursiva() throws Exception {

        try {
            Validator.checkDificuldade(radioDificuldadeFacil, radioDificuldadeMedio, radioDificuldadeDificil);
            
            Disciplina disciplina = DisciplinaController.consultar(comboDisciplinaQuestao.getSelectedItem().toString());
            Dificuldade dificuldade;
            
            if (radioDificuldadeFacil.isSelected()) {
                dificuldade = Dificuldade.FACIL;
            } else if (radioDificuldadeMedio.isSelected()) {
                dificuldade = Dificuldade.MEDIO;
            } else {
                dificuldade = Dificuldade.DIFICIL;
            }
            
            ArrayList<Topico> topicos = new ArrayList();                        
            for(Object item : listTopicosQuestao.getSelectedValues()){    
                Topico topico = DisciplinaController.recuperarTopico(disciplina, item.toString());
                System.out.println(item.toString());
                topicos.add(topico);
            }
            
            QuestaoDiscursiva questaoDiscursiva = QuestaoDiscursivaController.recuperar(disciplina, dificuldade, topicos);

            textEnunciado.setText(questaoDiscursiva.getEnunciado());            
            textGabaritoD.setText(questaoDiscursiva.getGabarito());
            idQuestaoDiscursiva = questaoDiscursiva.getDisciplina().getIdDisciplina();
            
        } catch (Exception e) {
            throw e;
        }
        

    }

    private void consultarQuestaoME() throws Exception {
        try {
            Validator.checkDificuldade(radioDificuldadeFacil, radioDificuldadeMedio, radioDificuldadeDificil);

            Disciplina disciplina = DisciplinaController.consultar(comboDisciplinaQuestao.getSelectedItem().toString());
            Dificuldade dificuldade;

            if (radioDificuldadeFacil.isSelected()) {
                dificuldade = Dificuldade.FACIL;
            } else if (radioDificuldadeMedio.isSelected()) {
                dificuldade = Dificuldade.MEDIO;
            } else {
                dificuldade = Dificuldade.DIFICIL;
            }       

            ArrayList<Topico> topicos = new ArrayList();                        
            for(Object item : listTopicosQuestao.getSelectedValues()){    
                Topico topico = DisciplinaController.recuperarTopico(disciplina, item.toString());
                System.out.println(item.toString());
                topicos.add(topico);
            }

            QuestaoMultiplaEscolha questaoME = QuestaoMultiplaEscolhaController.recuperar(disciplina, dificuldade, topicos); 
            
            textEnunciado.setText(questaoME.getEnunciado());
            
            ArrayList<Alternativa> alternativas = questaoME.getAlternativa();

            textAlternativaA.setText(alternativas.get(0).getTexto());
            if (alternativas.get(0).getGabarito()) {
                radioGabaritoA.setSelected(true);
            }
            textAlternativaB.setText(alternativas.get(1).getTexto());
            if (alternativas.get(1).getGabarito()) {
                radioGabaritoB.setSelected(true);
            }
            textAlternativaC.setText(alternativas.get(2).getTexto());
            if (alternativas.get(2).getGabarito()) {
                radioGabaritoC.setSelected(true);
            }
            textAlternativaD.setText(alternativas.get(3).getTexto());
            if (alternativas.get(3).getGabarito()) {
                radioGabaritoD.setSelected(true);
            }
            textAlternativaE.setText(alternativas.get(4).getTexto());
            if (alternativas.get(4).getGabarito()) {
                radioGabaritoE.setSelected(true);
            }

        } catch (Exception e) {
            throw e;
        }
    }

    private void buttonCriarMEActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_buttonCriarMEActionPerformed
        try {

            Validator.checkCampoVazio(textEnunciado.getText());
            Validator.checkCampoVazio(textAlternativaA.getText());
            Validator.checkCampoVazio(textAlternativaB.getText());
            Validator.checkCampoVazio(textAlternativaC.getText());
            Validator.checkCampoVazio(textAlternativaD.getText());
            Validator.checkCampoVazio(textAlternativaE.getText());

            Disciplina disciplina = new Disciplina();
            disciplina = DisciplinaController.consultar(comboDisciplinaQuestao.getSelectedItem().toString());

            ArrayList<Alternativa> alternativas = new ArrayList(5);

            Alternativa alternativaA = new Alternativa();
            alternativaA.setTexto(textAlternativaA.getText());
            alternativaA.setGabarito(radioGabaritoA.isSelected());
            alternativas.add(alternativaA);

            Alternativa alternativaB = new Alternativa();
            alternativaB.setTexto(textAlternativaB.getText());
            alternativaB.setGabarito(radioGabaritoB.isSelected());
            alternativas.add(alternativaB);

            Alternativa alternativaC = new Alternativa();
            alternativaC.setTexto(textAlternativaC.getText());
            alternativaC.setGabarito(radioGabaritoC.isSelected());
            alternativas.add(alternativaC);

            Alternativa alternativaD = new Alternativa();
            alternativaD.setTexto(textAlternativaD.getText());
            alternativaD.setGabarito(radioGabaritoD.isSelected());
            alternativas.add(alternativaD);

            Alternativa alternativaE = new Alternativa();
            alternativaE.setTexto(textAlternativaE.getText());
            alternativaE.setGabarito(radioGabaritoE.isSelected());
            alternativas.add(alternativaE);

            Dificuldade dificuldade;

            if (radioDificuldadeFacil.isSelected()) {
                dificuldade = Dificuldade.FACIL;
            } else if (radioDificuldadeMedio.isSelected()) {
                dificuldade = Dificuldade.MEDIO;
            } else {
                dificuldade = Dificuldade.DIFICIL;
            }
            
            ArrayList<Topico> topicos = new ArrayList();                        
            for(Object item : listTopicosQuestao.getSelectedValues()){                
                Topico topico = DisciplinaController.recuperarTopico(disciplina, item.toString());
                System.out.println(item.toString());
                topicos.add(topico);
            }

            QuestaoMultiplaEscolhaController.cadastrar(textEnunciado.getText(), dificuldade, alternativas, disciplina, topicos);

            JOptionPane.showMessageDialog(rootPane, Validator.MSG_QUESTAO_MULTIPLA_ESCOLHA_CRIADA);

        } catch (Exception e) {
            JOptionPane.showMessageDialog(rootPane, e.getMessage(), "Erro", JOptionPane.ERROR_MESSAGE);
        }
    }//GEN-LAST:event_buttonCriarMEActionPerformed

    private void buttonExcluirMEActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_buttonExcluirMEActionPerformed
        try {
            Validator.checkCampoVazio(textEnunciado.getText());
        } catch (Exception e) {
            JOptionPane.showMessageDialog(rootPane, e.getMessage(), "Erro", JOptionPane.ERROR_MESSAGE);
        }
    }//GEN-LAST:event_buttonExcluirMEActionPerformed

    private void buttonCriarDActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_buttonCriarDActionPerformed
        
        try {
            Validator.checkCampoVazio(textEnunciado.getText());
            Validator.checkCampoVazio(textGabaritoD.getText());

            Disciplina disciplina = new Disciplina();
            disciplina = DisciplinaController.consultar(comboDisciplinaQuestao.getSelectedItem().toString());

            Dificuldade dificuldade;
            if (radioDificuldadeFacil.isSelected()) {
                dificuldade = Dificuldade.FACIL;
            } else if (radioDificuldadeMedio.isSelected()) {
                dificuldade = Dificuldade.MEDIO;
            } else {
                dificuldade = Dificuldade.DIFICIL;
            }            
            
            ArrayList<Topico> topicos = new ArrayList();                        
            for(Object item : listTopicosQuestao.getSelectedValues()){                
                Topico topico = DisciplinaController.recuperarTopico(disciplina, item.toString());
                System.out.println(item.toString());
                topicos.add(topico);
            }
            
            System.out.println(topicos.toString());

            QuestaoDiscursivaController.cadastrar(textEnunciado.getText(), dificuldade, disciplina, textGabaritoD.getText(), topicos);

            JOptionPane.showMessageDialog(rootPane, Validator.MSG_QUESTAO_DISCURSIVA_CRIADA);

        } catch (Exception e) {
            JOptionPane.showMessageDialog(rootPane, e.getMessage(), "Erro", JOptionPane.ERROR_MESSAGE);
            Logger.getLogger(ProvaView.class.getName()).log(Level.SEVERE, null, e);
        }
    }//GEN-LAST:event_buttonCriarDActionPerformed

    private void buttonExcluirDActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_buttonExcluirDActionPerformed
        try {
            Validator.checkCampoVazio(textEnunciado.getText());

            if (idQuestaoDiscursiva == null) { //verifica efetuou consulta
                throw new Exception(Validator.MSG_CONSULTA_NECESSARIA);
            }
            QuestaoDiscursivaController questaoD = new QuestaoDiscursivaController();
            questaoD.excluir(idQuestaoDiscursiva);

            JOptionPane.showMessageDialog(rootPane, Validator.MSG_QUESTAO_DISCURSIVA_EXCLUIDA);

            textEnunciado.setText("");
            textGabaritoD.setText("");
        } catch (Exception e) {
            JOptionPane.showMessageDialog(rootPane, e.getMessage(), "Erro", JOptionPane.ERROR_MESSAGE);
        }
    }//GEN-LAST:event_buttonExcluirDActionPerformed

    private void comboDisciplinaQuestaoActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_comboDisciplinaQuestaoActionPerformed

        listarTopicosDisciplina(comboDisciplinaQuestao, listTopicosQuestaoModel);

    }//GEN-LAST:event_comboDisciplinaQuestaoActionPerformed

    private void buttonAdicionarTopicoActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_buttonAdicionarTopicoActionPerformed

        listTopicosDisciplinaModel.addElement(textTopico.getText());
        textTopico.setText("");
    }//GEN-LAST:event_buttonAdicionarTopicoActionPerformed

    private void comboDisciplinaProvaActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_comboDisciplinaProvaActionPerformed

        listarTopicosDisciplina(comboDisciplinaProva, listTopicosProvaModel);
    }//GEN-LAST:event_comboDisciplinaProvaActionPerformed

    private void buttonGerarProvaActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_buttonGerarProvaActionPerformed

        try {                                                 
            
            Validator.checkCampoGerarQuestoesProva(textMEFacil.getText());
            Validator.checkCampoGerarQuestoesProva(textMEMedia.getText());
            Validator.checkCampoGerarQuestoesProva(textMEDificil.getText());
            Validator.checkCampoGerarQuestoesProva(textDFacil.getText());
            Validator.checkCampoGerarQuestoesProva(textDMedia.getText());
            Validator.checkCampoGerarQuestoesProva(textDDificil.getText());
                    
            //ProvaController prova = new ProvaController();      
           //listTopicosProva.setSelectionInterval(0, listTopicosProva.getModel().getSize() - 1);
         
            Disciplina disciplina = DisciplinaController.consultar(comboDisciplinaProva.getSelectedItem().toString());
            ArrayList<Topico> topicos = new ArrayList();                        
            
            for(Object item : listTopicosProva.getSelectedValues()){    
                Topico topico = DisciplinaController.recuperarTopico(disciplina, item.toString());
                System.out.println(item.toString());
                topicos.add(topico);
            }
            try {
                   Gerar(disciplina, topicos, Integer.parseInt(textMEFacil.getText()),
                   Integer.parseInt(textMEMedia.getText()), Integer.parseInt(textMEDificil.getText()), Integer.parseInt(textDFacil.getText()),
                   Integer.parseInt(textDMedia.getText()), Integer.parseInt(textDDificil.getText()));
            }catch (Exception e){
                JOptionPane.showMessageDialog(rootPane, e.getMessage(), "Erro", JOptionPane.ERROR_MESSAGE);
                Logger.getLogger(ProvaView.class.getName()).log(Level.SEVERE, null, e);
            }
        }catch (Exception ex){
            JOptionPane.showMessageDialog(rootPane, ex.getMessage(), "Erro", JOptionPane.ERROR_MESSAGE);
            Logger.getLogger(ProvaView.class.getName()).log(Level.SEVERE, null, ex);
        } 
    }//GEN-LAST:event_buttonGerarProvaActionPerformed

    private void radioMEActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_radioMEActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_radioMEActionPerformed

    private void limparFormularioDisciplina() {
        textNomeDisciplina.setText("");
        textCodigo.setText("");
        textTopico.setText("");
        listTopicosDisciplinaModel.clear();
    }

    private void listarTopicosDisciplina(JComboBox comboDisciplina, DefaultListModel listDisciplina) {

        Disciplina disciplinaSelected = (Disciplina) comboDisciplina.getSelectedItem();

        List<Topico> topicos = DisciplinaController.listarTopicos(disciplinaSelected);

        listDisciplina.clear();

        for (Topico item : topicos) {
            listDisciplina.addElement(item);
        }
    }
    
    private void cadastrarDisciplina() throws Exception {
        Validator.checkCampoVazio(textCodigo.getText());

        listTopicosDisciplina.setSelectionInterval(0, listTopicosDisciplina.getModel().getSize() - 1);
        if (listTopicosDisciplina.isSelectionEmpty()) {
            throw new Exception();
        }

        Object listaTopicos[] = listTopicosDisciplina.getSelectedValues();

        DisciplinaController.cadastrar(textNomeDisciplina.getText(), textCodigo.getText(), listaTopicos, idDisciplina);
    }
          
    private int numQuestoes = 0;
    private static ArrayList<QuestaoMultiplaEscolha>  questoesME = new ArrayList();
    private static ArrayList<QuestaoDiscursiva> questoesD = new ArrayList();
    
    public void Gerar(Disciplina disciplina, List<Topico> ListaTopicos, int MEFacil, int MEMedio, int MEDificil, int DFacil, int DMedio, int DDificil) throws Exception {

        int i = 0;
        for(i=0;i<MEFacil;i++){
            numQuestoes++;
            QuestaoProva questao = new QuestaoProva();
            questao.setQuestaoME(QuestaoMultiplaEscolhaController.recuperar(disciplina, Dificuldade.FACIL, ListaTopicos));
            questoesME.add(questao.getQuestaoME());
        }
        i = 0;
        for(i=0;i<MEMedio;i++){   
            numQuestoes++;
            QuestaoProva questao = new QuestaoProva();
            questao.setQuestaoME(QuestaoMultiplaEscolhaController.recuperar(disciplina, Dificuldade.MEDIO, ListaTopicos));            
            questoesME.add(questao.getQuestaoME());
        }
        i = 0;
        for(i=0;i<MEDificil;i++){  
            numQuestoes++;
            QuestaoProva questao = new QuestaoProva();
            questao.setQuestaoME(QuestaoMultiplaEscolhaController.recuperar(disciplina, Dificuldade.DIFICIL, ListaTopicos));            
            questoesME.add(questao.getQuestaoME());
        }        
        i = 0;
        for(i=0;i<DFacil;i++){    
            numQuestoes++;
            QuestaoProva questao = new QuestaoProva();
            questao.setQuestaoD(QuestaoDiscursivaController.recuperar(disciplina, Dificuldade.FACIL, ListaTopicos));            
            questoesD.add(questao.getQuestaoD());
        }
        i = 0;
        for(i=0;i<DMedio;i++){   
            numQuestoes++;
            QuestaoProva questao = new QuestaoProva();
            questao.setQuestaoD(QuestaoDiscursivaController.recuperar(disciplina, Dificuldade.MEDIO, ListaTopicos));            
            questoesD.add(questao.getQuestaoD());
        }
        i = 0;
        for(i=0;i<DFacil;i++){  
            numQuestoes++;
            QuestaoProva questao = new QuestaoProva();
            questao.setQuestaoD(QuestaoDiscursivaController.recuperar(disciplina, Dificuldade.DIFICIL, ListaTopicos));            
            questoesD.add(questao.getQuestaoD());
        } 
        ExibirProva(questoesME, questoesD);
    }

    public void ExibirProva(ArrayList<QuestaoMultiplaEscolha> questoesME, ArrayList<QuestaoDiscursiva> questoesD) {

        String prova = "";
        int i = 0;

        for(QuestaoMultiplaEscolha questao : questoesME){
            i++;
            prova+="Questao " + i + "\n" + questao.getEnunciado() + "\n\n";
        }
        
        for(QuestaoDiscursiva questao : questoesD){
            i++;
            prova+="Questao " + i + "\n" + questao.getEnunciado() + "\n\n";            
        }        
        
        textQuestoesProva.setText(prova);

        buttonImprimirProva.addActionListener(new java.awt.event.ActionListener() {

            @Override
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                Imprimir(evt);
            }
        });

        buttonImprimirGabarito.addActionListener(new java.awt.event.ActionListener() {

            @Override
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                GerarGabarito(evt);
            }
        });
        frameProva.setVisible(true);
    }
        
    private void Imprimir(ActionEvent evt) {
        try {
           
            String html = "";
            int i = 1;
            
            for (QuestaoDiscursiva questao : questoesD) {
                html += "Questao " + i++ + " - ";
                html += questao.getEnunciado();
                html += "<br /><br />";
            }

            for (QuestaoMultiplaEscolha questao : questoesME) {
                int j = 1;
                
                html += "Questao " + i++ + " - ";
                html += questao.getEnunciado();
                 html += "<ol style='list-style-type: upper-alpha'>";
                for(Alternativa alternativa : questao.getAlternativa()){
                    html+="<li>"+alternativa.getTexto()+"</li>";
                    j++;
                } 
                html +="</ol>";
            }
                        
            JFileChooser fc = new JFileChooser(System.getProperty("user.dir"));  
            fc.setFileFilter(new TextFileFilter());
            int returnVal = fc.showSaveDialog(null);  
            
            if (returnVal == JFileChooser.APPROVE_OPTION) {
               File file = fc.getSelectedFile();
               FileWriter fw = new FileWriter(file+".html");
               fw.write(html);
               fw.close();
            }

        } catch (IOException e) {
            // Houve uma exceção
        }
    }

    
    public class TextFileFilter extends FileFilter {

        @Override
        public boolean accept(File f) {
            if (f.isDirectory()) {
                return true;
            }
            return f.getName().endsWith(".html");
        }

        @Override
        public String getDescription() {
            return "HTML files (*.html)";
        }
    }


    
    private void GerarGabarito(ActionEvent evt) {
    try {
            String html = "";
            int i = 1;
            
            for (QuestaoDiscursiva questao : questoesD) {
                html += "<strong>Questao " + i++ + " - </strong>";
                html += questao.getEnunciado();
                html += "<br />";
                html += "<strong>Gabarito</strong> - "+questao.getGabarito();
                html += "<br /><br />";
            }

            for (QuestaoMultiplaEscolha questao : questoesME) {
                int j = 1;

                html += "<strong>Questao " + i++ + " - </strong>";
                html += questao.getEnunciado();
                html += "<ol style='list-style-type: upper-alpha'>";
                for (Alternativa alternativa : questao.getAlternativa()) {
                    html += "<li>" + alternativa.getTexto();
                    if (alternativa.getGabarito()) {
                        html += "- Correta";
                    }
                    html += "</li>";
                    j++;
                }
                html += "</ol>";

            }

            JFileChooser fc = new JFileChooser(System.getProperty("user.dir"));  
            fc.setFileFilter(new TextFileFilter());
            int returnVal = fc.showSaveDialog(null);  
            
            if (returnVal == JFileChooser.APPROVE_OPTION) {
               File file = fc.getSelectedFile();
               FileWriter fw = new FileWriter(file+".html");
               fw.write(html);
               fw.close();
            }

        } catch (IOException e) {
            // Houve uma exceção
        }        

        
    }
    
    /**
     * @param args the command line arguments
     */
    public static void main(String args[]) {
        java.awt.EventQueue.invokeLater(new Runnable() {

            @Override
            public void run() {
                new ProvaView().setVisible(true);



            }
        });
    }
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JPanel AbaD;
    private javax.swing.JPanel AbaDisciplina;
    private javax.swing.JPanel AbaME;
    private javax.swing.JPanel AbaProva;
    private javax.swing.JPanel AbaQuestao;
    private javax.swing.JToggleButton buttonAdicionarTopico;
    private javax.swing.JButton buttonAlterarDisciplina;
    private javax.swing.JButton buttonConsultarDisciplina;
    private javax.swing.JButton buttonConsultarQuestao;
    private javax.swing.JButton buttonCriarD;
    private javax.swing.JButton buttonCriarDisciplina;
    private javax.swing.JButton buttonCriarME;
    private javax.swing.JButton buttonExcluirD;
    private javax.swing.JButton buttonExcluirDisciplina;
    private javax.swing.JButton buttonExcluirME;
    private javax.swing.JButton buttonGerarProva;
    private javax.swing.JButton buttonImprimirGabarito;
    private javax.swing.JButton buttonImprimirProva;
    private javax.swing.JComboBox comboDisciplinaProva;
    private javax.swing.JComboBox comboDisciplinaQuestao;
    private javax.swing.JFrame frameProva;
    private javax.swing.ButtonGroup grupoGabaritoME;
    private javax.swing.ButtonGroup grupoOpcoesDificuldade;
    private javax.swing.ButtonGroup grupoOpcoesQuestao;
    private javax.swing.JPanel jPanel1;
    private javax.swing.JPanel jPanel10;
    private javax.swing.JPanel jPanel6;
    private javax.swing.JPanel jPanel7;
    private javax.swing.JPanel jPanel8;
    private javax.swing.JPanel jPanel9;
    private javax.swing.JScrollPane jScrollPane1;
    private javax.swing.JScrollPane jScrollPane2;
    private javax.swing.JScrollPane jScrollPane3;
    private javax.swing.JScrollPane jScrollPane4;
    private javax.swing.JScrollPane jScrollPane5;
    private javax.swing.JTabbedPane jTabbedPane1;
    private javax.swing.JTabbedPane jTabbedPane2;
    private javax.swing.JLabel labelAlternativaA;
    private javax.swing.JLabel labelAlternativaB;
    private javax.swing.JLabel labelAlternativaC;
    private javax.swing.JLabel labelAlternativaD;
    private javax.swing.JLabel labelAlternativaE;
    private javax.swing.JLabel labelCodigo;
    private javax.swing.JLabel labelDDificeis;
    private javax.swing.JLabel labelDFaceis;
    private javax.swing.JLabel labelDMedias;
    private javax.swing.JLabel labelDificuldade;
    private javax.swing.JLabel labelDisciplina;
    private javax.swing.JLabel labelDisciplinaProva;
    private javax.swing.JLabel labelEnunciado;
    private javax.swing.JLabel labelGabaritoD;
    private javax.swing.JLabel labelGabaritoME;
    private javax.swing.JLabel labelMEDificeis;
    private javax.swing.JLabel labelMEFaceis;
    private javax.swing.JLabel labelMEMedias;
    private javax.swing.JLabel labelNomeDisciplina;
    private javax.swing.JLabel labelQuestoesD;
    private javax.swing.JLabel labelQuestoesProva;
    private javax.swing.JLabel labelTopico;
    private javax.swing.JLabel labelTopicos;
    private javax.swing.JLabel labelTopicosProva;
    private javax.swing.JList listTopicosDisciplina;
    private javax.swing.JList listTopicosProva;
    private javax.swing.JList listTopicosQuestao;
    private javax.swing.JRadioButton radioDificuldadeDificil;
    private javax.swing.JRadioButton radioDificuldadeFacil;
    private javax.swing.JRadioButton radioDificuldadeMedio;
    private javax.swing.JRadioButton radioDiscursiva;
    private javax.swing.JRadioButton radioGabaritoA;
    private javax.swing.JRadioButton radioGabaritoB;
    private javax.swing.JRadioButton radioGabaritoC;
    private javax.swing.JRadioButton radioGabaritoD;
    private javax.swing.JRadioButton radioGabaritoE;
    private javax.swing.JRadioButton radioME;
    private javax.swing.JTextField textAlternativaA;
    private javax.swing.JTextField textAlternativaB;
    private javax.swing.JTextField textAlternativaC;
    private javax.swing.JTextField textAlternativaD;
    private javax.swing.JTextField textAlternativaE;
    private javax.swing.JTextField textCodigo;
    private javax.swing.JTextField textDDificil;
    private javax.swing.JTextField textDFacil;
    private javax.swing.JTextField textDMedia;
    private javax.swing.JTextArea textEnunciado;
    private javax.swing.JTextField textGabaritoD;
    private javax.swing.JTextField textMEDificil;
    private javax.swing.JTextField textMEFacil;
    private javax.swing.JTextField textMEMedia;
    private javax.swing.JTextField textNomeDisciplina;
    private javax.swing.JLabel textQuestoesME;
    private javax.swing.JTextArea textQuestoesProva;
    private javax.swing.JTextField textTopico;
    // End of variables declaration//GEN-END:variables
    private DefaultListModel listTopicosDisciplinaModel = new DefaultListModel();
    private DefaultListModel listTopicosQuestaoModel = new DefaultListModel();
    private DefaultListModel listTopicosProvaModel = new DefaultListModel();
}
